<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

/**
 * Welcome Controller.
 * 
 * @class     Welcome
 * @author    Iqbal
 * @version   1.0.0
 * @copyright Copyright (c) 2014 IPPI (http://www.ippi.or.id)
 */
class Welcome extends CI_Controller {
    /**
     * Member Logged
     * 
     * @var object $member_logged
     */
    public $member_logged;

    /**
	 * Constructor.
	 */
	public function __construct()
    {
        parent::__construct();
        
        // Load model
        $this->load->model("model_kasus","m_kasus", TRUE);
        $this->load->model("model_event","m_event", TRUE);
        $this->load->model("model_news","m_news", TRUE);
        $this->load->model('model_donation','m_donation', TRUE);
        $this->load->model('model_donatur','m_donatur', TRUE);
        $this->load->model('model_elibrary','m_elibrary', TRUE);
        $this->load->model('model_member','m_member', TRUE);
        $this->load->model('model_gallery','m_gallery', TRUE);
        $this->load->model('model_services','m_services', TRUE);
        $this->load->model('model_contact','m_contact', TRUE);
        $this->load->model('model_slide','m_slide', TRUE);
        $this->load->model('model_fundrising','m_fundrising', TRUE);
        
        // Check is member logged in
        is_member_logged_in();
        
        // Set member logged
        $this->member_logged        = ippi_get_current_member();
    }
    
    /**
	 * Index function.
	 */
	public function index()
	{        
        $data   = array(
            'web_title'	            => "Welcome - Ikatan Perempuan Positif Indonesia",
            'main_view'             => 'front/welcome/welcome_main',
            'contact'               => $this->m_contact->get_contact(),
            'slideshow'             => $this->m_slide->get_all()->result(),
            'list_kasus'            => $this->m_kasus->get_kasus_map(),
            'list_services'         => $this->m_services->get_all(),
            'list_propinsi'         => $this->m_kasus->get_all_propinsi(),
            'list_event_archived'   => $this->m_event->get_event_archived(),
            'list_event_count'      => $this->m_event->count_all(),
            'list_news_archived'    => $this->m_news->get_news_archived(),
            'list_news_count'       => $this->m_news->count_all(),
            'list_elibrary'         => $this->m_elibrary->get_all(),
            'list_donatur'          => $this->m_donatur->get_all(),
            'list_video_gallery'    => $this->m_gallery->get_all_video(),
            'list_image_gallery'    => $this->m_gallery->get_all_image(),
        );
        
        if( ippi_isset( $this->member_logged ) ){
            $data['member_logged']  = $this->member_logged;
            $data['list_donation']  = $this->m_donation->get_all_donation($this->member_logged->id_member);
            $data['donation_value'] = get_option('donation_value');
            $data['donation_mode']  = get_option('donation_mode');
            $data['donation_bank']  = get_option('donation_bank');
        }
        
        $this->load->view('front/template',$data);
	}
    
    /**
	 * Index function.
     * 
     * @param[in] int $id Member ID
	 */
    public function chat($id=0){
        if( !empty($id) && $id > 0 ){
            $member_logged          = $this->m_member->get_memberdata($id);
        }else{
            $member_logged          = $this->member_logged;
        }
        
        $data['member']             = $member_logged;
        $this->load->view('front/welcome/welcome_chat', $data);
    }
    
    function debug(){
        $donation_mode  = get_option('donation_mode');
        $mode_new       = Array
        (
            'cash'              => 'Tunai (Cash)',
            'transfer'          => 'Transfer',
            'mobile-banking'    => 'Mobile Banking',
            'internet-banking'  => 'Internet Banking'
        );
                
        echo "<pre>";
        print_r($donation_mode);
        die();
    }
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */